﻿<Window x:Class="DatabaseTunning.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:DatabaseTunning"
        mc:Ignorable="d"
        Title="MainWindow"
        Height="350"
        Width="525">
    <Window.Resources>
        <local:ObjectToFormatStringConverter x:Key="ObjectToFormatStringConverter" />
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <StackPanel>
            <StackPanel Orientation="Horizontal">
                <TextBlock Margin="10"
                           Text="Loại địa điểm" />
                <TextBox MinWidth="200"
                         Margin="10"
                         Text="{Binding Place, Mode=TwoWay}" />
                <Button Margin="0,10"
                        Padding="10,0"
                        Content="Đọc dữ liệu"
                        Command="{Binding LoadCommand}" />
            </StackPanel>
            <TextBlock Margin="10,0"
                       Text="{Binding LoadText}" />
            <StackPanel Orientation="Horizontal">
                <ComboBox Margin="10"
                          MinWidth="120"
                          SelectedIndex="{Binding DistanceMode, Mode=TwoWay}">
                    <ComboBoxItem Content="MINDIST" />
                    <ComboBoxItem Content="MINMAXDIST" />
                </ComboBox>
                <ComboBox Margin="0,10"
                          MinWidth="200"
                          SelectedIndex="{Binding Algorithm, Mode=TwoWay}">
                    <ComboBoxItem Content="Thuật toán tham lam" />
                    <ComboBoxItem Content="Thuật toán dùng hàng đợi" />
                    <ComboBoxItem Content="Thuật toán tham lam mở rộng" />
                    <ComboBoxItem Content="Thuật toán tham lam mở rộng 2" />
                </ComboBox>
                <Button Margin="10"
                        Padding="10,0"
                        Content="Chạy"
                        Command="{Binding RunCommand}" />
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <TextBlock Margin="10,0"
                           Text="X:" />
                <TextBox MinWidth="50"
                         Text="{Binding X, Mode=TwoWay}" />
                <TextBlock Margin="10,0"
                           Text="Y:" />
                <TextBox MinWidth="50"
                         Text="{Binding Y, Mode=TwoWay}" />
                <TextBlock Margin="10,0"
                           Text="k:" />
                <TextBox MinWidth="50"
                         Text="{Binding K, Mode=TwoWay}" />
                <TextBlock Margin="10,0"
                           Text="scale:" />
                <TextBox MinWidth="50"
                         Text="{Binding Scale, Mode=TwoWay}" />
            </StackPanel>
            <TextBlock Margin="10"
                       Text="{Binding Time, ConverterParameter='Thời gian: \{0:\} ms', Converter={StaticResource ObjectToFormatStringConverter}}" />
        </StackPanel>
        <ListView x:Name="resultListView"
                  Margin="10,0"
                  Grid.Row="1"
                  ItemsSource="{Binding Result}">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Grid Width="{Binding ActualWidth, ElementName=resultListView}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition Width="200" />
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="{Binding Value}" />
                        <TextBlock Grid.Column="1"
                                   Text="{Binding Distance}" />
                    </Grid>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </Grid>
</Window>